import {Modal, Descriptions, Tag} from 'antd';
import dayjs from 'dayjs';
import {LessonTypeMap, LessonStatus} from "@/constants/LessonConstants";
import React from "react";

interface LessonDetailModalProps {
  visible: boolean;
  onCancel: () => void;
  lesson?: API.ILesson;
}

const LessonDetailModal: React.FC<LessonDetailModalProps> = ({
                                                               visible,
                                                               onCancel,
                                                               lesson,
                                                             }) => {
  return (
    <Modal
      title="课程详情"
      width={800}
      open={visible}
      onCancel={onCancel}
      footer={null}
      destroyOnClose
    >
      <Descriptions column={2} bordered>
        <Descriptions.Item label="课程ID">{lesson?.id}</Descriptions.Item>
        <Descriptions.Item label="教练">{lesson?.coachName}</Descriptions.Item>
        <Descriptions.Item label="车牌号">{lesson?.plateNumber}</Descriptions.Item>
        <Descriptions.Item
          label="驾照类型">{`${lesson?.licenseTypeName}-${lesson?.licenseTypeCode}`}</Descriptions.Item>
        <Descriptions.Item label="课程类型">
          <Tag color={(LessonTypeMap as Record<string, {
            text: string;
            color: string
          }>)[lesson?.courseType || '1']?.color}>
            {(LessonTypeMap as Record<string, { text: string; color: string }>)[lesson?.courseType || '1']?.text}
          </Tag>
        </Descriptions.Item>
        <Descriptions.Item label="开始时间">
          {dayjs(lesson?.startTime).format('YYYY-MM-DD HH:mm')}
        </Descriptions.Item>
        <Descriptions.Item label="结束时间">
          {dayjs(lesson?.endTime).format('YYYY-MM-DD HH:mm')}
        </Descriptions.Item>
        <Descriptions.Item label="预约状态">
          <Tag color={(LessonStatus as Record<string, { text: string; color: string }>)[lesson?.status || '']?.color}>
            {(LessonStatus as Record<string, { text: string; color: string }>)[lesson?.status || '']?.text}
          </Tag>
        </Descriptions.Item>
        <Descriptions.Item label="签到口令">{lesson?.password}</Descriptions.Item>
        <Descriptions.Item label="学员数量">
          {lesson?.currentStudents} / {lesson?.maxStudents}
        </Descriptions.Item>
        <Descriptions.Item label="备注" span={2}>
          {lesson?.remark || '无'}
        </Descriptions.Item>
      </Descriptions>
    </Modal>
  );
};

export default LessonDetailModal;
